#include "public.h"
#include "smg.h"
#include "key.h"
#include "at24c02.h"

#define EEPROM_ADDRESS 0 //定义数据存入 EEPROM 的起始地址

void main()
{
	u8 key=0;
	u8 save_values = 0;
	u8 save_buf[3];
	while(1)
	{
		key = key_scan(0);
		if (key==KEY1_PRESS)
		{
			AT24CXX_WriteOneByte(EEPROM_ADDRESS, save_values);
		}
		else if (key==KEY2_PRESS)
		{
			save_values=AT24CXX_ReadOneByte(EEPROM_ADDRESS);
		}
		else if (key==KEY3_PRESS)
		{
			save_values++;
			if(save_values==255) save_values=255;
		}
		else if (key==KEY4_PRESS)
		{
			save_values=0;
		}
		save_buf[0]=save_values/100;
		save_buf[1]=save_values%100/10;
		save_buf[2]=save_values%100%10;
		smg_display(save_buf, 6);
	}
}